#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QListWidget>




MainWindow::MainWindow(QWidget *parent)
    : QDialog(parent)
{

    resize(1000,800);
    move(400,100);
    setSizeGripEnabled(true);

    QGridLayout* pMainWindowGridLayout = new QGridLayout(this);


    QLabel* pLabel = new QLabel(this);
    pLabel->setText("push button:");
    pLabel->resize(300,100);


    QPushButton* pPushButton = new QPushButton(this);
    pPushButton->setText("push button");
    pPushButton->resize(100,50);

    QListWidget* pList = new QListWidget(this);
    QListWidgetItem *pListWidgetItem = new QListWidgetItem("锄禾日当午"); // 设置水平头
    pListWidgetItem->setTextAlignment(Qt::AlignCenter);// 设置格式（居中）
    QColor TempColor(255,255,0);
    pListWidgetItem->setBackgroundColor(TempColor);
    pList->addItem(pListWidgetItem);
    pList->resize(300,300);


    pMainWindowGridLayout->addWidget(pLabel,0,0);
    pMainWindowGridLayout->addWidget(pPushButton,1,1);
    pMainWindowGridLayout->addWidget(pList,2,3);
    pMainWindowGridLayout->setSizeConstraint(QLayout::SetMinimumSize);

    setWindowTitle(tr("Dynamic Layouts"));
}

MainWindow::~MainWindow()
{

}

